/*
 * TestFul - http://code.google.com/p/testful/
 * Copyright (C) 2010  Matteo Miraz
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package instrumentation;

import java.io.Serializable;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Set;

import soot.SootMethod;

public class DataUse implements Serializable {

	private static final long serialVersionUID = -372367168640928525L;
	private final int id;
	private static int idGenerator = 1;

	private final soot.Value data;
	private final String cName;
	private final String method;
		/**
	 * Create a data usage
	 * @param data the data being used
	 * @param blockDefs the block's definitions before this usage
	 */
	public DataUse(String cName,String method, soot.Value data) {
		id = idGenerator++;

		this.cName=cName;
		this.method=method;

		this.data = data;
//		this.data.addUse(this);
	}

	public int getId() {
		return id;
	}
	public String getCName(){
		return this.cName;
	}
public String getMName(){
		return this.method;
	}

	public soot.Value getData() {
		return data;
	}





	public String getDataUseString() {

		StringBuilder sb = new StringBuilder();
		sb.append(this.cName);
		sb.append(".");
		sb.append(this.method);
		sb.append(" return field" );
		sb.append(this.getData());
		
		
		return sb.toString();
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
//		sb.append(this.cName);
//		sb.append(".");
		sb.append(this.method);
///		sb.append(" return field" );
//		sb.append(this.getData());
		
		
		return sb.toString();
	}
}
